package com.ljfiction.book.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.ljfiction.book.R;

/**
 * Created by Android on 2018/1/23.
 */

public class WxkefuDialog {
    private Dialog mDialog;
    private Button imageView;

    public WxkefuDialog(Context context) {
        mDialog = new Dialog(context, R.style.ActionSheetDialogStyle);
        View view = LayoutInflater.from(context).inflate(R.layout.wxerweima, null);
        imageView=view.findViewById(R.id.diss);
        //将布局设置给Dialog
        mDialog.setContentView(view);
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = context.getResources().getDisplayMetrics().widthPixels;
        view.setLayoutParams(layoutParams);
        mDialog.getWindow().setGravity(Gravity.TOP);
        mDialog.getWindow().setWindowAnimations(R.style.ActionSheetDialogAnimation);
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.setCancelable(false);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mDialog!=null){
                    mDialog.dismiss();
                }
            }
        });
    }

    public void show() {
        if (mDialog != null) {
            mDialog.show();
        }
    }
}
